﻿define(['require', 'jquery', 'knockout', 'viewModel/UserInfoViewModel', 'viewModel/MenuViewModel'],
function (require, $, ko, UserInfoViewModel, MenuViewModel) {
    return function MainViewModel() {
        //construction logic
        this.init = function () {
            this.UserInfoViewModel = new UserInfoViewModel();
            this.MenuViewModel = new MenuViewModel();

            this.LoadUserInfoView();
            this.LoadMenuView();
        };

        this.LoadUserInfoView = function () {
            var that = this;
            $('#UserInfoViewContainer').load('../view/UserInfoView.htm #UserInfoView', function () {
                ko.applyBindings(that.UserInfoViewModel, document.getElementById('UserInfoView'));
                console.log('Loaded UserInfoView');
            });
        };

        this.LoadMenuView = function () {
            var that = this;
            $('#MenuViewContainer').load('../view/MenuView.htm #MenuView', function () {
                ko.applyBindings(that.MenuViewModel, document.getElementById('MenuView'));
                console.log('Loaded MenuViewContainer');
            });
        };

        this.UserInfoViewModel = null;
        this.MenuViewModel = null;

        //contruction execution
        this.init();
    };
});
      